﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:calendarprimitives="using:Looptribe.WinRT.Toolkit.Controls.CalendarPrimitives">

    <ResourceDictionary.ThemeDictionaries>
        <ResourceDictionary
            x:Key="Default">
            <SolidColorBrush
                x:Key="CalendarRegularDayBackgroundFillBrush"
                Color="#FFFFFFFF" />
            <SolidColorBrush
                x:Key="CalendarNonRegularDayBackgroundFillBrush"
                Color="#FFDDDDDD" />
        </ResourceDictionary>
    </ResourceDictionary.ThemeDictionaries>

    <Style
        TargetType="calendarprimitives:CalendarDay">
        
        <Setter
            Property="BorderThickness"
            Value="1" />
        <Setter
            Property="Padding"
            Value="0" />
        
        <Setter
            Property="Template">
            <Setter.Value>
                <ControlTemplate
                    TargetType="calendarprimitives:CalendarDay">
                    <Grid
                        x:Name="Root">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup
                                x:Name="DayStates">
                                <VisualState
                                    x:Name="RegularDay" />
                                <VisualState
                                    x:Name="NonRegularDay">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="DayBackground"
                                            Storyboard.TargetProperty="Fill">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource CalendarNonRegularDayBackgroundFillBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                            <Grid
                                Margin="{TemplateBinding Padding}">
                                <Rectangle
                                    x:Name="DayBackground"
                                    Fill="{StaticResource CalendarRegularDayBackgroundFillBrush}" />
                                <StackPanel>
                                    <TextBlock
                                        Text="{Binding Day}"
                                        FontWeight="Bold"
                                        HorizontalAlignment="Left"
                                        VerticalAlignment="Top"
                                        Margin="2,2,10,5" />
                                    <ItemsControl ItemsSource="{Binding Events}" ItemTemplate="{TemplateBinding ItemTemplate}" />
                                </StackPanel>
                            </Grid>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>